package org.dbrd.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.Properties;

public class PropertiesReader {
	
	public static Properties readProperties(StringReader reader) throws IOException {
		BufferedReader in  =new BufferedReader(reader);
		Properties p = new Properties();
		String key;
		String value;
		int index;
		for (String line = in.readLine(); line != null; line = in.readLine()) {
			if (line.startsWith("#")) {
				continue;
			}
			index = line.indexOf('=');
			if (index < 0) {
				throw new IOException("invalid string line: " + line);
			}
			key = line.substring(0, index);
			value = line.substring(index + 1);
			p.put(key, value);
		}
		return p;
	}
	
}
